package metier.sess;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import metier.entities.Langue;
import metier.entities.Message;


@Stateless(name="Message")
public class MessageEJBImpl implements IMessageLocal{
	
	@PersistenceContext(unitName="PU_Cargaison")
	private EntityManager em;

	@Override
	public void addMessage(Message a) {
		em.persist(a);
		
	}

	@Override
	public List<Message> getAllMessage() 
	{
		
		Query	req=em.createQuery("select sp from Message sp ");
		return req.getResultList();
		
	}

	@Override
	public Message getMessage(Integer Id) {
		return em.find(Message.class, Id);
	}

	@Override
	public void updateMessage(Message a) {
	em.merge(a);
		
	}

	@Override
	public void deleteMessage(Integer Id) {
	em.remove(getMessage(Id));
		
	}
	
	

}
